<template>
	<view>
		<view class="cy_list">
			<view v-show="jiazai==false">
				<!-- 				<text class="cy_li_tit t22" v-if="serviceAmount">费率:</text>
				<text class="cy_li_tit t20 tri" v-if="serviceAmount">{{serviceAmount/100}}元</text>
				<text class="cy_li_tit t22" v-if="redAmount">用户返红包:</text>
				<text class="cy_li_tit t20 tri" v-if="redAmount">{{redAmount/100}}元</text>
				<text class="cy_li_tit t22" v-if="seamount">实际收益:</text>
				<text class="cy_li_tit t20 tri" v-if="seamount">{{seamount/100}}元</text>
				<text class="cy_li_tit t20 tri" v-if="cuowu">{{cuowu}}</text> -->
				<view class="cy_li">
					<view class="cy_li_item">
						<view class="cy_li_tit t22">费率</view>
						<view class="t20">{{serviceAmount/100}}元</view>
					</view>
					<view class="cy_li_item">
						<view class="cy_li_tit t22">用户返红包</view>
						<view class="t20">{{redAmount/100}}元</view>
					</view>
					<view class="cy_li_item">
						<view class="cy_li_tit t22">实际收益</view>
						<view class="t20">{{seamount/100}}元</view>
					</view>
				</view>

				<view class="cy_li">
					<view class="cy_li_item">
						<view class="cy_li_tit t22">观看用户</view>
						<view class="t20">{{payerNickName}}</view>
					</view>
					<view class="cy_li_item">
						<view class="cy_li_tit t22">客户端</view>
						<view class="t20">{{client}}</view>
					</view>
					<view class="cy_li_item">
						<view class="cy_li_tit t22">观看日期</view>
						<view class="t20">{{createdTime}}</view>
					</view>
				</view>


				<view class="button-user" @click="userAnalysis()">查看用户明细</view>


			</view>
			<view class="zanwu" v-show="jiazai" style="padding-top: 4vw;padding-bottom: 3vw;"><text
					class="t7">当前收益无分润明细</text></view>
		</view>


	</view>
</template>
<script>
	export default {
		data() {
			return {
				mainid: '',
				serviceAmount: '',
				redAmount: '',
				id: '',
				jiazai: true,
				amount: 0,
				seamount: 0,
				cuowu: '',
				payerNickName: '',
				payType: 0,
				createdTime: '',
				client: '',
			}
		},
		onLoad(opt) {
			if (opt.id) {
				this.id = opt.id;
				this.amount = opt.amount;
				this.payerNickName = opt.payerNickName
				this.payType = opt.payType
				this.createdTime = opt.createdTime
				this.client = this.getClient(this.payType)
				console.log("this.client: ", this.client);
			}
			uni.getStorage({
				key: 'user',
				success: res => {
					this.mainid = res.data.id;
					this.getDetail();
				}
			});
		},
		methods: {
			getDetail() {
				let data = {
					id: this.id
				}
				this.$request.post(`mch/getTradeSplitInfo/${this.id}`, data)
					.then(res => {
						console.log("收益详情 res:", res)
						if (res.data.status == '200') {
							if (res.data.data) {
								this.jiazai = false;
								let info = JSON.parse(res.data.data.info);
								console.log(info.serviceAmount);
								if (res.data.data.status == 0) {
									if (info.errMsg) {
										this.cuowu = info.errMsg;
									}
								}
								this.serviceAmount = info.serviceAmount;
								this.redAmount = info.redAmount;
								this.seamount = this.amount - this.serviceAmount - this.redAmount;
							} else {

								this.jiazai = true;
							}
						}
					}).catch(err => {
						console.log("收益详情 err:", err)
						uni.hideLoading();
						uni.showToast({
							title: error,
							icon: 'none',
							duration: 2000
						});
					})
			},
			getClient(type) {
				switch (type) {
					case '1':
						return '招财阿咪';
					case '2':
						return '';
					case '3':
						return '微信';
					case '4':
						return '支付宝';
					case '5':
						return '微信小程序';
					default:
						break;
				}
			},
			userAnalysis() {
				uni.navigateTo({
					url: '/pages/statistics/statistics-user?payerNickName='+this.payerNickName
				});
			}

		}
	}
</script>

<style>
	.cy_list {
		width: 90%;
		height: auto;
		margin: 2vw 5%;
		box-shadow: 0px 0px 5px #F2F2F2;
		border-radius: 1vw;
	}

	.cy_li {
		width: 100%;
		height: auto;
		padding: 4vw 0;
		background: #fff;
		margin-top: 20upx;

	}

	.cy_li .cy_li_item {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin: 0 20upx;
	}

	.cy_li_tit {
		height: 10vw;
		line-height: 10vw;
	}


	.button-user {
		margin: auto;
		width: 80%;
		height: 70upx;
		line-height: 70upx;
		background: linear-gradient(#F1C75E, #d4a93c);
		border-radius: 6upx;
		text-align: center;
		color: #FFFFFF;
		font-size: 30upx;
		margin-top: 50upx;

	}
</style>
